<template>
<div class="user">
    <!--内容-->
    <div class="product-content">
      <div class="table-wrap">
        <el-table size="small" :data="tableData" border style="width: 100%" v-loading="loading">
          <el-table-column prop="userId" :label="$t('plus.user_id')"></el-table-column>
          <el-table-column prop="realName" :label="$t('plus.distributor')"></el-table-column>
          <el-table-column prop="oldGradeName" :label="$t('plus.original_level')"></el-table-column>
          <el-table-column prop="newGradeName" :label="$t('plus.new_level')"></el-table-column>
          <el-table-column :label="$t('plus.upgrade_method')">
            <template  #default="scope">
              <span v-if="scope.row.changeType == 10" class="green">{{$t('plus.admin_action')}}</span>
              <span v-if="scope.row.changeType == 20">{{$t('plus.auto_upgrade')}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="createTime" :label="$t('plus.upgrade_time')"></el-table-column>
        </el-table>
      </div>
    </div>
    <!--分页-->
    <div class="pagination">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        background
        :current-page="curPage"
        :page-size="pageSize"
        layout="total, prev, pager, next, jumper"
        :total="totalDataNumber"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import GradeApi from '@/api/plus/agent/grade.js';
export default {
  data() {
    return {
      /*是否加载完成*/
      loading: true,
      /*列表数据*/
      tableData: [],
      /*一页多少条*/
      pageSize: 20,
      /*一共多少条数据*/
      totalDataNumber: 0,
      /*当前是第几页*/
      curPage: 1
    };
  },
  created() {
    /*获取列表*/
    this.getData();
  },
  methods: {
    /*选择第几页*/
    handleCurrentChange(val) {
      let self = this;
      self.curPage = val;
      self.loading = true;
      self.getData();
    },
    /*每页多少条*/
    handleSizeChange(val) {
      this.curPage = 1;
      this.getData();
    },
    /*获取列表*/
    getData() {
      let self = this;
      let Params = {};
      Params.pageIndex = self.curPage;
      Params.pageSize = self.pageSize;
      GradeApi.loglist(Params, true).then(res => {
        self.loading = false;
        self.tableData = res.data.records;
        self.totalDataNumber = res.data.total;
      }).catch(error => {});
    }
  }
};
</script>

